<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    // 小例子
    let lessons = [
      {
        title: "语文",
        category: "优秀",
      },
      { title: "数学", category: "极好" },
      { title: "英语", category: "一般" },
    ];
    let res = lessons.reduce((obj, cur, index) => {
      obj[`${cur.category}-${index + 1}`] = cur;
      return obj;
    }, {});
    console.log(JSON.stringify(res, null, 2));

    // 合并两个对象，如果待合并的对象相同，那后面的对象就会把前面的给覆盖掉
    let test = Object.assign({ a: 1 }, { b: 2 });
    console.log(test);
  </script>
</html>
